<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="../tpl/header.html" /}
</head>
<body>
{include file="../tpl/menu.html" /}
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" method="post" action="{:url('admin/admin/userEdit')}">

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>登录名</label>
                <div class="layui-input-inline">
                    <input name="username" value="{$data.username}" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名,可填写字符串或者中文
                </div>
            </div>

            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" value="{$data.name}" id="name" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>展示的姓名,请填写管理员的真实姓名
                </div>
            </div>

            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red">*</span>手机
                </label>
                <div class="layui-input-inline">
                    <input type="text" value="{$data.phone}" id="phone" readonly name="phone"  autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名
                </div>
            </div>

            <div class="layui-form-item">
                <label for="L_email" class="layui-form-label">
                    邮箱
                </label>
                <div class="layui-input-inline">
                    <input type="text" value="{$data.email}" id="L_email" name="email" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    邮箱地址,可用来接收推送信息
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>角色</label>
                <div class="layui-input-block">
                    {foreach name="role_list" item="vo"}
                    <input type="radio" value="{$key}" name="role_id" lay-skin="primary" title="{$vo.name}" {if condition="$data['role_id'] eq $key"}checked="checked"{/if} />
                    {/foreach}
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">
                    密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="L_pass" name="password"  autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    (不修改密码请留空)6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                    确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="L_repass" name="password1" autocomplete="off" class="layui-input">
                </div>
            </div>
            <input type="hidden" name="uid" value="{$data['uid']}">
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form, layer = layui.layer;
            //监听提交
            form.on('submit(add)', function(data) {
                $.ajax({
                    type:'post',
                    data:data.field,
                    dataType:'json',
                    url:"{:url('admin/admin/userEdit')}",
                    success:function (e) {
                        if(e.code === 1){
                            layer.msg(e.msg, {icon: 6,time: layer_msg_success_time},
                                function() {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.location.reload();
                                });
                        }else{
                            layer.msg(e.msg, {icon: 5,time: layer_msg_error_time});
                        }
                    }
                });
                //发异步，把数据提交给php
                return false;
            });
        });
</script>
</body>
</html>